#include <stdio.h>
#include <string.h>
#include <stdlib.h>

// 先定义结构体类型
// 再指定形参为结构体类型
struct Dog {
    char *name;
    int age;
    double weight;
};

char *show(struct Dog);

int main(){

    struct Dog dog = {"大黄", 5, 17.9};
    char *info = show(dog);
    printf("%s", info);

    return 0;
}

char *show(struct Dog dog){
    char *info = (char *)malloc(100 * sizeof(char));
    char *text = (char *)malloc(100 * sizeof(char));
    sprintf(text, "名字：%s\n", dog.name);
    strcat(info, text);
    sprintf(text, "年龄：%d\n", dog.age);
    strcat(info, text);
    sprintf(text, "体重：%lf\n", dog.weight);
    strcat(info, text);

    return info;
}